package org.ucas.kgraph.dto;

import com.alibaba.fastjson.JSON;
import com.google.common.base.Defaults;
import org.springframework.http.HttpStatus;
import org.ucas.kgraph.entity.Account;
import org.ucas.kgraph.entity.Perm;
import org.ucas.kgraph.entity.Term;
import org.ucas.kgraph.utils.exception.NotFoundException;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 词条的Dto对象
 * @author suemi
 */
public class AccountDto  {

  public Long id;

  public String name;
  
  public String role;
  
  public String page;

  public String realname;
  public static AccountDto of(Account account){
    
    AccountDto accountDto = new AccountDto();
    accountDto.id = account.getId();
    accountDto.name =account.getUserProfile().getName();
    if(account.getUserProfile().getName()==null){
    	accountDto.name = account.getName();
    }else if(account.getUserProfile().getName().length()==0){
    	accountDto.name = account.getName();
    }
    
    accountDto.role = account.getRolesName().toString();
    accountDto.page = "user";
    for(int j = 0;j<account.getRoleList().size();j++){
    	List<Perm> permList = account.getRoleList().get(j).getPermList();
    	for(int i = 0;i<permList.size();i++){
    		if(permList.get(i).getName().equals("admin")){
    			accountDto.page = "admin";
    		}
    	}
    }
    return accountDto;
  }



public Long getId() {
	return id;
}



public void setId(Long id) {
	this.id = id;
}



public String getName() {
	return name;
}



public void setName(String name) {
	this.name = name;
}

 
}
